<?php

/**
 * This is the model class for table "catalog".
 *
 * The followings are the available columns in table 'catalog':
 * @property integer $id
 * @property string $href
 * @property string $name
 * @property string $preview
 * @property string $id_3d
 * @property string $title_3d
 * @property string $body
 * @property string $brand
 * @property string $brand_rus
 * @property string $artikul
 * @property string $pic
 * @property string $pic_alt
 * @property string $pic_title
 * @property string $header
 * @property string $title
 * @property string $keywords
 * @property string $description
 * @property string $type
 * @property string $visibility
 * @property integer $level
 * @property integer $position
 * @property string $slide
 * @property string $proizvoditel
 * @property string $equipment
 * @property string $scope
 * @property double $cost
 * @property double $cost_old
 * @property string $status
 * @property string $passport_data
 * @property string $availability
 * @property string $used_complete
 * @property string $featured_products
 * @property integer $changed
 * @property string $language
 * @property string $guarantee
 * @property string $in_the_packing_pieces
 */
class Catalog extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Catalog the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'catalog';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('href, name, preview, id_3d, title_3d, body, brand, brand_rus, artikul, pic, pic_alt, pic_title, header, title, keywords, description, proizvoditel, equipment, scope, cost_old, used_complete, featured_products, guarantee, in_the_packing_pieces', 'required'),
			array('level, position, changed', 'numerical', 'integerOnly'=>true),
			array('cost, cost_old', 'numerical'),
			array('href, name, id_3d, title_3d, brand_rus, artikul, pic, pic_alt, pic_title, header, title, keywords, description, proizvoditel, equipment, scope, used_complete, featured_products, guarantee', 'length', 'max'=>255),
			array('brand', 'length', 'max'=>150),
			array('type', 'length', 'max'=>7),
			array('visibility, slide, passport_data, availability', 'length', 'max'=>1),
			array('status', 'length', 'max'=>6),
			array('language', 'length', 'max'=>2),
			array('in_the_packing_pieces', 'length', 'max'=>15),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, href, name, preview, id_3d, title_3d, body, brand, brand_rus, artikul, pic, pic_alt, pic_title, header, title, keywords, description, type, visibility, level, position, slide, proizvoditel, equipment, scope, cost, cost_old, status, passport_data, availability, used_complete, featured_products, changed, language, guarantee, in_the_packing_pieces', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'href' => 'Href',
			'name' => 'Name',
			'preview' => 'Preview',
			'id_3d' => 'Id 3d',
			'title_3d' => 'Title 3d',
			'body' => 'Body',
			'brand' => 'Brand',
			'brand_rus' => 'Brand Rus',
			'artikul' => 'Artikul',
			'pic' => 'Pic',
			'pic_alt' => 'Pic Alt',
			'pic_title' => 'Pic Title',
			'header' => 'Header',
			'title' => 'Title',
			'keywords' => 'Keywords',
			'description' => 'Description',
			'type' => 'Type',
			'visibility' => 'Visibility',
			'level' => 'Level',
			'position' => 'Position',
			'slide' => 'Slide',
			'proizvoditel' => 'Proizvoditel',
			'equipment' => 'Equipment',
			'scope' => 'Scope',
			'cost' => 'Cost',
			'cost_old' => 'Cost Old',
			'status' => 'Status',
			'passport_data' => 'Passport Data',
			'availability' => 'Availability',
			'used_complete' => 'Used Complete',
			'featured_products' => 'Featured Products',
			'changed' => 'Changed',
			'language' => 'Language',
			'guarantee' => 'Guarantee',
			'in_the_packing_pieces' => 'In The Packing Pieces',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('href',$this->href,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('preview',$this->preview,true);
		$criteria->compare('id_3d',$this->id_3d,true);
		$criteria->compare('title_3d',$this->title_3d,true);
		$criteria->compare('body',$this->body,true);
		$criteria->compare('brand',$this->brand,true);
		$criteria->compare('brand_rus',$this->brand_rus,true);
		$criteria->compare('artikul',$this->artikul,true);
		$criteria->compare('pic',$this->pic,true);
		$criteria->compare('pic_alt',$this->pic_alt,true);
		$criteria->compare('pic_title',$this->pic_title,true);
		$criteria->compare('header',$this->header,true);
		$criteria->compare('title',$this->title,true);
		$criteria->compare('keywords',$this->keywords,true);
		$criteria->compare('description',$this->description,true);
		$criteria->compare('type',$this->type,true);
		$criteria->compare('visibility',$this->visibility,true);
		$criteria->compare('level',$this->level);
		$criteria->compare('position',$this->position);
		$criteria->compare('slide',$this->slide,true);
		$criteria->compare('proizvoditel',$this->proizvoditel,true);
		$criteria->compare('equipment',$this->equipment,true);
		$criteria->compare('scope',$this->scope,true);
		$criteria->compare('cost',$this->cost);
		$criteria->compare('cost_old',$this->cost_old);
		$criteria->compare('status',$this->status,true);
		$criteria->compare('passport_data',$this->passport_data,true);
		$criteria->compare('availability',$this->availability,true);
		$criteria->compare('used_complete',$this->used_complete,true);
		$criteria->compare('featured_products',$this->featured_products,true);
		$criteria->compare('changed',$this->changed);
		$criteria->compare('language',$this->language,true);
		$criteria->compare('guarantee',$this->guarantee,true);
		$criteria->compare('in_the_packing_pieces',$this->in_the_packing_pieces,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}